![]() |
PATH![]() |
![]() ![]() |
Considering and Ignoring statements cause AppleScript to consider or ignore specific characteristics, called attributes, as it executes groups of statements.
considering attribute [, attribute ... and attribute ] ¬
[ but ignoring attribute [, attribute ... and attribute ] ]
[ statement ]...
end considering
ignoring attribute [, attribute ... and attribute ] ¬
[ but considering attribute [, attribute ... and attribute ] ]
[ statement ]...
end ignoring
statement is any AppleScript statement.
attribute is an attribute to be considered or ignored. Attributes are listed next under "Attributes".
An attribute is a characteristic that can be considered or ignored in a Considering or Ignoring statement. A Considering or Ignoring statement can include any of the following attributes:
application responses : AppleScript waits for a response from each application command before proceeding to the next statement or operation. The response indicates if the command completed successfully, and also returns results and error messages, if there are any. If this attribute is ignored, AppleScript does not wait for responses from application commands before proceeding to the next statement, and ignores any results or error messages that are returned. Results and error messages from AppleScript commands, scripting additions, and expressions are not affected by the application responses attribute.
case : In string comparisons, uppercase letters are not distinguished from lowercase letters. If this attribute is considered, uppercase letters are distinguished from lowercase letters. See Greater Than, Less Than for a description of how AppleScript sorts letters, punctuation, and other symbols.
diacriticals : Diacritical marks (such as ´, `, ^, ¨, and ~) are considered in string comparisons. If this attribute is ignored, "résumé" is considered equal to "resume" , and so on. See Greater Than, Less Than for a description of how AppleScript sorts letters with diacritical marks.
expansion : In string comparisons, AppleScript treats the characters æ, Æ, , and as identical to the character pairs ae, AE, oe, and OE, respectively. If this attribute is ignored, AppleScript treats these characters like single characters; for example æ would be considered not equal to the character pair ae.
hyphens : In string comparisons, hyphenated words are considered different from their nonhyphenated counterparts. If this attribute is ignored, the strings are compared as if any hyphens were not present; for example "anti-war" would be considered equal to "antiwar" .
punctuation : The punctuation marks (. , ? : ; ! \ ' " `) are considered in string comparisons. If this attribute is ignored, the strings are compared as if these punctuation marks were not present; for example "This!" would be considered equal to "This" .
white space : Spaces, tab characters, and return characters are considered in string comparisons. If this attribute is ignored, the strings are compared as if these characters were not present; for example "Brick house" would be considered equal to "Brickhouse" .
"BOB" comes before "bob" --result: false
considering case
"BOB" comes before "bob" --result: true
end considering
"a" comes before "á" --result: true
ignoring diacriticals
"a" comes before "á" --result: false
end considering
"Babs" comes before "bábs" --result: true
ignoring case
"Babs" comes before "bábs" --result: true
end ignoring
ignoring case and diacriticals
"Babs" comes before "bábs" --result: false
end ignoring
ignoring punctuation
"this !,:book" = "this book" --result: true
end ignoring
--result: Dialog is displayed.
The case , white space , diacriticals , hyphens , expansion , and punctuation considerations apply only to comparisons performed by AppleScript. Comparisons are performed by AppleScript if the first operand in the comparison is a value in a script; if the first operand is a reference to an application or system object, the comparison is performed by the application or operating system.
In contrast, the application responses consideration applies only to application commands. AppleScript commands, scripting additions, and AppleScript expressions are not affected.
As with all other control statements, you can nest Considering and Ignoring statements. If the same attribute appears in both an outer and inner statement, the attribute specified in the inner statement takes precedence. For example, in the following statement, the first comparison is true , because case attribute is ignored (as specified in the Ignoring statement), while the second comparison is false , because the case attribute is once again considered (as specified in the inner Considering statement).
ignoring case and punctuation
if "This" = "this" then beep 1 --true
considering case
if "This" = "this" then beep 2 --false
end considering
end considering
--result: Beeps once.
When attributes in an inner Considering or Ignoring statement are different from those in outer statements, they are added to the attributes to be considered and ignored. For example, in the following statement, the first comparison is false , because only case is ignored, while the second comparison is true , because both case and white space are ignored.
ignoring case
if "This or that" = "thisorthat" then beep 2 --false
ignoring white space
if "This or that" = "thisorthat" then beep 1 --true
end ignoring
end ignoring
--result: Beeps once.